package bank;

import java.util.Map;
import javax.xml.namespace.QName;
import javax.xml.ws.BindingProvider;
import javax.xml.ws.Service;

public class BankWSClientFactory {
	
	public static void main(String args[]) throws Exception{
		RemoteBankService create = create("http://localhost:9080/bank-api-0.0.1-SNAPSHOT/BankWebService");
	}
	
	public static RemoteBankService create(String endpoint_address) {
		QName serviceName = new QName("http://bank/", "BankWebServiceService");
		String classpathWsdlLocation = "/BankWebService.wsdl";

		Service service = Service.create(RemoteBankService.class.getResource(classpathWsdlLocation), serviceName);
		RemoteBankService client = service.getPort(RemoteBankService.class);
		Map<String, Object> requestContext = ((BindingProvider) client).getRequestContext();
		requestContext.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,endpoint_address);

		return client;
	}
}